/**
 * Pagination.java
 *
 *
 * $LastChangedBy: allen $
 * $LastChangedDate: 2007-12-07 14:20:34 +0800 $
 * $Revision: 1398 $
 */
package com.myspace.view.common;

public class Pagination {

	private int curPage;

	private int total;

	private int totalPage;

	private int pageSize;

	public Pagination(int curPage, int pageSize, int total) {
		this.total = total;
		if (pageSize == 0) {
			this.pageSize = Constant.PAGE_SIZE;
		}else{
			this.pageSize = pageSize;
		}
		this.totalPage = (this.total % this.pageSize == 0 ? this.total
				/ this.pageSize : (this.total / this.pageSize + 1));
		if (curPage < 1) {
			this.curPage = 1;
		}else if (curPage > totalPage) {
			this.curPage = totalPage;
		}else{
			this.curPage = curPage;
		}
	}

	public int getCurPage() {
		return this.curPage;
	}

	public int getTotalPage() {
		return this.totalPage;
	}

	public int getTotal() {
		return total;
	}

	public int getPageSize() {
		return pageSize;
	}

	public boolean isHasNextPage() {
		return this.curPage < this.totalPage;
	}

	public boolean isHasPrevPage() {
		return this.curPage > 1;
	}
}
